import java.util.*;
import java.lang.*;

public class Instruction
{
  private int x;
  private int y;
  private int instructionType;
  public static final int SAD = 0;
  public static final int RESET = 1;
  public static final int QRESET = 2;
  
  public Instruction(int newX,int newY)
  {
    x = newX;
	y = newY;
	instructionType = SAD;
  }
  
  public Instruction()
  {
	instructionType = RESET;
  }
  
  public Instruction(String inst)
  {
    if(inst.equals("RESET"))
	{
	  instructionType = RESET;
	}
	else if(inst.equals("QRESET"))
	{
	  instructionType = QRESET;
	}
  }
  
  public int getX() { return x; }
  public int getY() { return y; }
  public boolean isReset() { return instructionType == RESET; }
  public boolean isQReset() { return instructionType == QRESET; }
  public boolean isSAD() {return instructionType == SAD;}
  public int getInstructionType() {return instructionType;}
  
  public String toString()
  {
    if(isReset()) return "RESET";
	else if(isQReset()) return "QRESET";
	else if(isSAD()) return "X: " + x + " Y: " + y;
	else return "Error";
  }
  
  public static Instruction getRandomInstruction(double resetProbability, double standardDeviation)
  {
    Random generator = new Random();
    double random1 = generator.nextDouble();
    if(random1 < resetProbability * 0.5) return new Instruction("RESET");
	else if(random1 < resetProbability) return new Instruction("QRESET");
	int random2 = (int)Math.round((generator.nextGaussian()) * standardDeviation);
	int random3 = (int)Math.round((generator.nextGaussian()) * standardDeviation);
	return new Instruction(random2,random3);
  }
}